home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 2207 / 2207.xpi / chrome / cooliris.jar / content / cooliris / coolirisPagePreviews.js < prev    next >
Text File  |  2010-01-28  |  27KB  |  1,032 lines

  1. var cpvw_iconDelayController={linkViewCount:0,maxDelay:2000,increment:100,thresholdCount:15,reset:function(){
  2. var _1=cpvw_objOverlay.getContentDocument();
  3. _1.iconDelayTime=null;
  4. this.linkViewCount=0;
  5. },increaseDelay:function(){
  6. var _2=cpvw_objOverlay.getContentDocument();
  7. if(!_2){
  8. return;
  9. }
  10. if(!_2.iconDelayTime){
  11. _2.iconDelayTime=parseInt(cpvw_prefHandler.getPref(cpvw_Prefs.prefMouseIconDelay),10);
  12. this.linkViewCount=0;
  13. }
  14. this.linkViewCount++;
  15. if(this.linkViewCount>this.thresholdCount){
  16. if(_2.iconDelayTime<this.maxDelay){
  17. _2.iconDelayTime+=this.increment;
  18. }
  19. }
  20. },getIconDelayTime:function(){
  21. var _3=cpvw_objOverlay.getContentDocument();
  22. if(_3&&_3.iconDelayTime){
  23. return _3.iconDelayTime;
  24. }
  25. return cpvw_prefHandler.getPref(cpvw_Prefs.prefMouseIconDelay);
  26. }};
  27. function cpvw_clsPreview(_4){
  28. this.parentDoc=_4;
  29. this.popTimer=null;
  30. this.linkUrl="";
  31. this.pageX=0;
  32. this.pageY=0;
  33. this.openDelayTime=cpvw_Delays.OPEN_DELAY_TIME;
  34. this.closeDelayTime=0;
  35. this.isShowingPreview=false;
  36. this.isShowingSmallDiv=false;
  37. this.dimPreview=null;
  38. this.prefetchIndex=0;
  39. this.prefetchTimer=null;
  40. this.prefetchDelay=cpvw_Delays.PREFETCH_DELAY_TIME;
  41. this.hideTimer=null;
  42. this.dispDelayTime=cpvw_Delays.DISPLAY_DELAY_TIME;
  43. this.dispTimer=null;
  44. this.doneHighlight=false;
  45. this.highlightTimer=null;
  46. this.smallDivTimer=null;
  47. this.showSmallDivTimer=null;
  48. this.newHistory=null;
  49. this.aIndex=0;
  50. this.prefetchIndex=0;
  51. this.prefetchLinks=[];
  52. cpvw_previewHandler.customSite="";
  53. this.hText="";
  54. this.linkElem=null;
  55. this.pushpin=false;
  56. this.enablePreview=true;
  57. this.curIndex=0;
  58. this.arrLinks=null;
  59. this.evt=null;
  60. this.mouseoverIconTimer=null;
  61. }
  62. cpvw_clsPreview.prototype={setup:function(){
  63. var _5=cpvw_previewHandler.getPreviewFrame();
  64. _5.addEventListener("DOMContentLoaded",cpvw_previewHandler,false);
  65. _5.addEventListener("CoolPreviewsCoolirisDontShow",cpvw_previewHandler,false,true);
  66. _5.addEventListener("CoolPreviewsCoolirisContinue",cpvw_previewHandler,false,true);
  67. },clearTimer:function(_6){
  68. if(_6==this.popTimer){
  69. clearTimeout(this.popTimer);
  70. this.popTimer=null;
  71. }else{
  72. if(_6==this.hideTimer){
  73. clearTimeout(this.hideTimer);
  74. this.hideTimer=null;
  75. }else{
  76. if(_6==this.dispTimer){
  77. clearTimeout(this.dispTimer);
  78. this.dispTimer=null;
  79. }else{
  80. if(_6==this.smallDivTimer){
  81. clearTimeout(this.smallDivTimer);
  82. this.smallDivTimer=null;
  83. }else{
  84. if(_6==this.showSmallDivTimer){
  85. clearTimeout(this.showSmallDivTimer);
  86. this.showSmallDivTimer=null;
  87. }else{
  88. clearTimeout(_6);
  89. }
  90. }
  91. }
  92. }
  93. }
  94. },startPrefetch:function(){
  95. var _7=this.parentDoc.location.href;
  96. var _8=Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
  97. _8.spec=_7;
  98. var _9=this;
  99. for(var i=0;i<this.prefetchLinks.length;i++){
  100. var _b=this.prefetchLinks[i];
  101. var _c=Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
  102. _c.spec=_b;
  103. var _d=Components.classes["@mozilla.org/prefetch-service;1"].createInstance(Components.interfaces.nsIPrefetchService);
  104. try{
  105. _d.prefetchURI(_c,_8,true);
  106. }
  107. catch(ex){
  108. }
  109. }
  110. },afterPrefetch:function(_e){
  111. if(this.prefetchTimer){
  112. clearTimeout(this.prefetchTimer);
  113. }
  114. this.prefetchIndex++;
  115. if(this.prefetchIndex>=this.prefetchLinks.length){
  116. var _f=document.getElementById("frmPrefetch");
  117. if(_f!=null){
  118. document.getElementById("main-window").removeChild(_f);
  119. }
  120. return;
  121. }
  122. this.startPrefetch();
  123. },convertLinks:function(){
  124. var doc=this.parentDoc;
  125. this.prefetchLinks=[];
  126. this.arrLinks=[];
  127. var _11=this.parentDoc.getElementsByTagName("a");
  128. doc.addEventListener("DOMNodeInserted",function(evt){
  129. var _13=evt.target;
  130. var _14;
  131. if(_13 instanceof HTMLLinkElement){
  132. _14=[];
  133. _14.push(_13);
  134. cpvw_docHandler.modifyLinks(_14);
  135. }else{
  136. if(_13.getElementsByTagName){
  137. _14=_13.getElementsByTagName("a");
  138. cpvw_docHandler.modifyLinks(_14);
  139. }
  140. }
  141. },false);
  142. this.modifyLinks(_11);
  143. },modifyLinks:function(_15){
  144. var _16=this;
  145. var _17=[];
  146. var _18=[];
  147. var _19=false;
  148. for(var i=0;i<navigator.mimeTypes.length;i++){
  149. if(navigator.mimeTypes[i].type.toLowerCase()=="application/pdf"){
  150. _19=true;
  151. }
  152. }
  153. for(i=0;i<_15.length;i++){
  154. if(_15[i].href.toString().indexOf("http")==-1||_15[i].href.toString().indexOf("#")==_15[i].href.toString().length-1||_15[i].href.toString().toLowerCase().indexOf("logout")!=-1||_15[i].href.toString().toLowerCase().indexOf("signin")!=-1||_15[i].href.toString().toLowerCase().indexOf("login")!=-1||_15[i].href.toString().toLowerCase().indexOf("signout")!=-1){
  155. continue;
  156. }
  157. if(cpvw_previewHandler.customSite=="google_search"){
  158. var _1b=_15[i].href.toString().indexOf("/",8);
  159. if(_15[i].href.toString().indexOf("/webhp")!=-1){
  160. continue;
  161. }
  162. }
  163. if(cpvw_previewHandler.customSite=="technorati"){
  164. if(_15[i].href.toString().indexOf("www.technorati.com/search")!=-1||_15[i].href.toString().indexOf("www.technorati.com/faves")!=-1){
  165. continue;
  166. }
  167. }
  168. if(cpvw_previewHandler.customSite=="delicious"){
  169. if(_15[i].href.toString().indexOf("delete=")!=-1){
  170. continue;
  171. }
  172. }
  173. var _1c=""+_15[i].href;
  174. if(_1c.match(/\.(pdf)$/i)){
  175. if(!_19){
  176. continue;
  177. }
  178. }
  179. if(_15[i].getAttribute("set")=="yes"){
  180. continue;
  181. }
  182. _15[i].setAttribute("linkIndex",this.arrLinks.length);
  183. _15[i].addEventListener("mouseover",function(evt){
  184. var _1e=this;
  185. cpvw_docHandler.curIndex=parseInt(this.getAttribute("linkIndex"));
  186. cpvw_docHandler.evt=evt;
  187. _16.previewOpen(evt,this.href,this);
  188. },true);
  189. _15[i].addEventListener("mouseout",function(evt){
  190. var _20=this;
  191. _16.previewClose(evt);
  192. },false);
  193. _15[i].addEventListener("click",function(evt){
  194. var _22=this.href.toString();
  195. if(cpvw_previewHandler.previewOpenMode=="click"&&(!cpvw_docHandler.isShowingPreview||cpvw_docHandler.linkUrl!=_22)){
  196. cpvw_docHandler.openDelayTime=0;
  197. cpvw_docHandler.dispDelayTime=500;
  198. cpvw_docHandler.initPreviewShow(evt,this.href,this);
  199. evt.preventDefault();
  200. }else{
  201. _16.initPreviewHide(evt);
  202. cpvw_previewHandler.hidePreview();
  203. }
  204. },false);
  205. if(_1c.match(/\.(pdf|doc|xls|ppt)$/i)){
  206. continue;
  207. }
  208. this.arrLinks.push(_15[i].getAttribute("href"));
  209. if(_15[i].id==""){
  210. _18.push(_15[i]);
  211. }else{
  212. _17.push(_15[i]);
  213. }
  214. }
  215. this.prefetchLinks=this.prefetchLinks.concat(_18,_17);
  216. },getCurrentIndex:function(url){
  217. var _24=-1;
  218. for(var i=0;i<this.arrLinks.length;i++){
  219. var _26=this.arrLinks[i];
  220. if(cpvw_previewHandler.customSite=="google_search"){
  221. if(_26==url){
  222. return i;
  223. }
  224. }else{
  225. if(cpvw_previewHandler.customSite=="yahoo_search"){
  226. url=url.replace(":","%3a");
  227. if(_26.indexOf(url)!=-1){
  228. return i;
  229. }
  230. }
  231. }
  232. }
  233. return _24;
  234. },findNextGoogleLink:function(){
  235. var _27=cpvw_previewHandler.getPreviewFrame();
  236. var _28=_27.contentDocument;
  237. var _29=this.getCurrentIndex(_28.URL);
  238. var _2a=(_29==-1)?cpvw_docHandler.curIndex:_29;
  239. for(var i=_2a+1;i<this.arrLinks.length;i++){
  240. var _2c=this.arrLinks[i];
  241. if(_2c==null){
  242. continue;
  243. }
  244. var uri=Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
  245. uri.spec=_2c;
  246. if(cpvw_previewHandler.customSite=="google_search"){
  247. if(uri.host.indexOf("google")!=-1||(_2c.indexOf("/search")!=-1||_2c.indexOf("q=cache")!=-1)){
  248. continue;
  249. }else{
  250. break;
  251. }
  252. }else{
  253. if(cpvw_previewHandler.customSite=="yahoo_search"){
  254. if(_2c.indexOf("cache.search")!=-1){
  255. continue;
  256. }else{
  257. break;
  258. }
  259. }
  260. }
  261. }
  262. return i;
  263. },displayNextLink:function(){
  264. if(this.arrLinks.length==0){
  265. return;
  266. }
  267. var _2e="";
  268. if(cpvw_previewHandler.customSite!="google_search"&&cpvw_previewHandler.customSite!="yahoo_search"){
  269. cpvw_docHandler.curIndex++;
  270. }else{
  271. cpvw_docHandler.curIndex=this.findNextGoogleLink();
  272. }
  273. if(cpvw_docHandler.curIndex>this.arrLinks.length){
  274. cpvw_docHandler.curIndex=0;
  275. }
  276. _2e=this.arrLinks[cpvw_docHandler.curIndex];
  277. if(cpvw_previewHandler.customSite=="google_search"){
  278. if(_2e.charAt(0)=="/"){
  279. _2e="http://www.google.com"+_2e;
  280. }
  281. }
  282. this.popTimer=setTimeout(function(){
  283. cpvw_docHandler.showPreview(_2e);
  284. },10);
  285. },handleKeyPress:function(evt){
  286. if(evt.keyCode==32){
  287. cpvw_docHandler.openDelayTime=cpvw_Delays.OPEN_DELAY_TIME;
  288. cpvw_docHandler.dispDelayTime=cpvw_Delays.DISPLAY_DELAY_TIME;
  289. cpvw_docHandler.initPreviewShow(evt,href,elem);
  290. }
  291. },previewClose:function(evt){
  292. var _31=this;
  293. if(cpvw_previewHandler.previewOpenMode=="direct"){
  294. _31.initPreviewHide(evt);
  295. }else{
  296. if(cpvw_previewHandler.previewOpenMode=="icon"){
  297. _31.clearTimer(_31.showSmallDivTimer);
  298. if(!_31.smallDivTimer){
  299. _31.smallDivTimer=setTimeout(function(){
  300. _31.removeSmallDiv();
  301. },2000);
  302. }
  303. if(_31.isShowingPreview){
  304. _31.initPreviewHide(evt);
  305. }
  306. }else{
  307. if(cpvw_previewHandler.previewOpenMode=="click"){
  308. _31.clearTimer(_31.popTimer);
  309. _31.clearTimer(_31.dispTimer);
  310. }else{
  311. if(cpvw_previewHandler.previewOpenMode=="hotkey"&&evt.ctrlKey){
  312. _31.initPreviewHide(evt);
  313. }
  314. }
  315. }
  316. }
  317. },previewOpen:function(evt,_33,_34){
  318. var _35=this;
  319. if(!_35.parentDoc.enablePreview){
  320. return;
  321. }
  322. if(cpvw_previewHandler.previewOpenMode=="direct"){
  323. _35.openDelayTime=cpvw_Delays.OPEN_DELAY_TIME;
  324. _35.dispDelayTime=cpvw_Delays.DISPLAY_DELAY_TIME;
  325. _35.initPreviewShow(evt,_33,_34);
  326. }else{
  327. if(cpvw_previewHandler.previewOpenMode=="icon"||cpvw_previewHandler.previewOpenMode=="icon-click"){
  328. _35.openDelayTime=500;
  329. _35.dispDelayTime=500;
  330. _35.clearTimer(_35.smallDivTimer);
  331. cpvw_iconDelayController.increaseDelay();
  332. if(_35.isShowingPreview){
  333. _35.initPreviewShow(evt,_33,_34);
  334. }else{
  335. _35.showSmallDivTimer=setTimeout(function(){
  336. _35.showSmallDiv(evt,_33,_34);
  337. },cpvw_iconDelayController.getIconDelayTime());
  338. }
  339. }else{
  340. if(cpvw_previewHandler.previewOpenMode=="click"){
  341. _35.clearTimer(_35.hideTimer);
  342. }else{
  343. if(cpvw_previewHandler.previewOpenMode=="hotkey"&&evt.ctrlKey){
  344. _35.openDelayTime=100;
  345. _35.dispDelayTime=500;
  346. _35.initPreviewShow(evt,_33,_34);
  347. }
  348. }
  349. }
  350. }
  351. },getElementPosition:function(_36){
  352. var _37=0;
  353. var _38=0;
  354. if(_36){
  355. var _39=_36.offsetParent;
  356. if(_39){
  357. while((_39=_36.offsetParent)!=null){
  358. _37+=_36.offsetLeft;
  359. _38+=_36.offsetTop;
  360. _36=_39;
  361. }
  362. }else{
  363. _37=_36.offsetLeft;
  364. _38=_36.offsetTop;
  365. }
  366. }
  367. return {"px":_37,"py":_38};
  368. },getIconPosition:function(_3a){
  369. var _3b=this.parentDoc.createElement("span");
  370. _3b.setAttribute("id","cpvw_temporaryElement");
  371. _3b.innerHTML=" adfd";
  372. if(_3a.nodeType==1){
  373. _3a.parentNode.insertBefore(_3b,_3a.nextSibling);
  374. var _3c=_3b.offsetLeft;
  375. var _3d=_3b.offsetTop;
  376. if(_3b.offsetParent){
  377. var _3e=_3b;
  378. while(_3e.offsetParent){
  379. _3c+=_3e.offsetParent.offsetLeft;
  380. _3d+=_3e.offsetParent.offsetTop;
  381. _3e=_3e.offsetParent;
  382. }
  383. }
  384. _3a.parentNode.removeChild(_3b);
  385. }else{
  386. if(_3a.nodeType==3){
  387. var _3f=_3a.splitText(endOffset);
  388. _3a.parentNode.insertBefore(_3b,_3f);
  389. _3c=_3b.offsetLeft;
  390. _3d=_3b.offsetTop;
  391. if(_3b.offsetParent){
  392. var _3e=_3b;
  393. while(_3e.offsetParent){
  394. _3c+=_3e.offsetParent.offsetLeft;
  395. _3d+=_3e.offsetParent.offsetTop;
  396. _3e=_3e.offsetParent;
  397. }
  398. }
  399. _3a.parentNode.removeChild(_3b);
  400. }
  401. }
  402. return {"px":_3c,"py":_3d};
  403. },showSmallDiv:function(evt,_41,_42){
  404. if(this==cpvw_docHandler){
  405. evt=cpvw_docHandler.evt;
  406. }
  407. var _43=this;
  408. if(!_43.parentDoc.enablePreview){
  409. return;
  410. }
  411. var pos=_43.getElementPosition(_42);
  412. var px,py,_47=40;
  413. var _48;
  414. if(cpvw_prefHandler.getPref(cpvw_Prefs.prefFixedIcon)){
  415. var _49;
  416. if(!cpvw_jsUtils.isFF2()){
  417. var _4a=_42.getClientRects();
  418. var _4b=_4a.length;
  419. var _4c=_42.ownerDocument.defaultView.pageYOffset;
  420. var _4d=_42.ownerDocument.defaultView.pageXOffset;
  421. for(var k=0;k<_4b;k++){
  422. _48=_4a[k];
  423. if(evt.pageY<_4c+_4a[k].bottom){
  424. break;
  425. }
  426. }
  427. pos.py=_4c+_48.bottom-16;
  428. _49=_48.right;
  429. }else{
  430. if((pos.px+_42.offsetWidth)>_42.ownerDocument.defaultView.innerWidth){
  431. var _4f=_43.getIconPosition(_42);
  432. _49=_4f.px;
  433. pos.py=_4f.py;
  434. }else{
  435. _49=pos.px+_42.offsetWidth+5;
  436. }
  437. }
  438. px=_49+10;
  439. }else{
  440. if(!cpvw_jsUtils.isFF2()){
  441. var _4a=_42.getClientRects();
  442. var _4b=_4a.length;
  443. var _4c=_42.ownerDocument.defaultView.pageYOffset;
  444. var _4d=_42.ownerDocument.defaultView.pageXOffset;
  445. for(var k=0;k<_4b;k++){
  446. _48=_4a[k];
  447. if(evt.pageY<_4c+_4a[k].bottom){
  448. break;
  449. }
  450. }
  451. pos.py=_4c+_48.bottom-16;
  452. if(evt.pageX-_47<(_4d+_48.left)){
  453. if(evt.pageX+20>(_4d+_48.right)){
  454. px=_4d+_48.right;
  455. }else{
  456. px=evt.pageX+_47+20;
  457. }
  458. }else{
  459. px=evt.pageX-_47-20;
  460. }
  461. }else{
  462. if(_42.offsetWidth+_42.offsetLeft>_42.ownerDocument.defaultView.innerWidth){
  463. px=pos.px-20;
  464. pos.py=evt.pageY;
  465. }else{
  466. if(evt.screenX-_47<pos.px){
  467. if(evt.screenX+_47+20>pos.px+_42.offsetWidth){
  468. px=pos.px+_42.offsetWidth;
  469. }else{
  470. px=evt.screenX+_47+20;
  471. }
  472. }else{
  473. px=evt.screenX-_47-20;
  474. }
  475. }
  476. }
  477. }
  478. pos.px=px;
  479. if(_43.curLink==_42){
  480. return;
  481. }
  482. _43.removeSmallDiv(true);
  483. if(!_43.isShowingPreview&&!_43.isShowingSmallDiv){
  484. var _50=_43.parentDoc.createElement("img");
  485. _50.setAttribute("src","chrome://cooliris/skin/new/mouseover.png");
  486. _50.setAttribute("id","cpvw_smallDivTip");
  487. _50.setAttribute("style","z-index:2147483647;border: 0px solid blue;-moz-opacity:0.20;position:absolute;width:20px;height:20px;");
  488. var _51=function(){
  489. _50.style.opacity=parseFloat(_50.style.opacity)+0.2;
  490. if(parseFloat(_50.style.opacity)<0.9){
  491. setTimeout(_51,75);
  492. }
  493. };
  494. setTimeout(_51,50);
  495. _50.style.left=pos.px+"px";
  496. _50.style.top=pos.py+"px";
  497. _43.parentDoc.body.appendChild(_50);
  498. _43.isShowingSmallDiv=true;
  499. _43.curLink=_42;
  500. _50.addEventListener("mouseover",function(evt){
  501. if(cpvw_previewHandler.previewOpenMode=="icon-click"){
  502. return;
  503. }
  504. _43.clearTimer(_43.smallDivTimer);
  505. clearTimeout(_43.smallDivRemoveTimer);
  506. _50.style.opacity=0.9;
  507. _43.mouseX=evt.screenX;
  508. _43.mouseY=evt.screenY;
  509. if(evt.altKey){
  510. if(_41!=cpvw_stackManager.prevUrl){
  511. cpvw_stackManager.addToStack(null,_41);
  512. }
  513. }else{
  514. _43.mouseoverIconTimer=setTimeout(function(){
  515. _43.initPreviewShow(evt,_41,_42);
  516. },cpvw_Delays.PREVIEW_ON_ICON_DELAY);
  517. }
  518. },true);
  519. _50.addEventListener("click",function(evt){
  520. clearTimeout(_43.smallDivTimer);
  521. clearTimeout(_43.smallDivRemoveTimer);
  522. _50.style.opacity=0.9;
  523. _43.mouseX=evt.screenX;
  524. _43.mouseY=evt.screenY;
  525. if(evt.altKey){
  526. if(_41!=cpvw_stackManager.prevUrl){
  527. cpvw_stackManager.addToStack(null,_41);
  528. }
  529. }else{
  530. _43.initPreviewShow(evt,_41,_42);
  531. }
  532. },true);
  533. _50.addEventListener("mouseout",function(evt){
  534. clearTimeout(_43.mouseoverIconTimer);
  535. _43.initPreviewHide(evt);
  536. _43.removeSmallDiv();
  537. },true);
  538. _43.smallDivTimer=setTimeout(function(){
  539. _43.removeSmallDiv();
  540. },3000);
  541. }else{
  542. _43.initPreviewShow(evt,_41,_42);
  543. }
  544. },removeSmallDiv:function(_55){
  545. var _56=this;
  546. var _57=_56.parentDoc.getElementById("cpvw_smallDivTip");
  547. if(_55){
  548. _56.isShowingSmallDiv=false;
  549. cpvw_docHandler.curLink=null;
  550. if(cpvw_imageDocHandler){
  551. cpvw_imageDocHandler.curLink=null;
  552. }
  553. if(_57!=null){
  554. _56.parentDoc.body.removeChild(_57);
  555. clearTimeout(_56.smallDivTimer);
  556. }
  557. }else{
  558. if(_57!=null){
  559. _57.style.opacity=parseFloat(_57.style.opacity)-0.1;
  560. if(parseFloat(_57.style.opacity)>0){
  561. _56.smallDivRemoveTimer=setTimeout(function(){
  562. _56.removeSmallDiv();
  563. },120);
  564. }else{
  565. _56.removeSmallDiv(true);
  566. }
  567. }
  568. }
  569. },initPreviewShow:function(evt,_59,_5a,_5b){
  570. this.clearTimer(this.hideTimer);
  571. var _5c=this;
  572. cpvw_iconDelayController.reset();
  573. var _5d=cpvw_prefHandler.getPref(cpvw_Prefs.prefPreviewEnable);
  574. if((_5d=="no"||!_5c.parentDoc.enablePreview)&&!_5b){
  575. return;
  576. }
  577. conDump("gool search "+cpvw_previewHandler.customSite+",  "+_59);
  578. if(cpvw_previewHandler.customSite=="google_search"&&(_59.indexOf("http://www.google.com/pagead/iclk")!=-1||_59.indexOf("http://www.google.com/url")!=-1)){
  579. var _5e=_59.split("&");
  580. for(var i=0;i<_5e.length;i++){
  581. if(_5e[i].indexOf("adurl=")!=-1){
  582. _59=_5e[i].substr(6);
  583. _59=unescape(_59);
  584. }
  585. }
  586. }
  587. if(cpvw_previewHandler.customSite=="yahoo_search"&&(_59.indexOf("overture.com")!=-1)){
  588. var _60=_59.indexOf("yargs=");
  589. if(_60!=-1){
  590. _59=_59.substr(_60+6);
  591. _59=unescape(_59);
  592. if(_59.indexOf("http://")==-1&&_59.indexOf("https://")==-1){
  593. _59="http://"+_59;
  594. }
  595. }
  596. }
  597. _5c.loadSubSearchBar();
  598. this.pageX=evt.pageX;
  599. this.pageY=evt.pageY;
  600. this.screenX=evt.screenX;
  601. this.screenY=evt.screenY;
  602. if(this.linkUrl==_59&&this.isShowingPreview){
  603. this.setPreviewDimensions();
  604. return;
  605. }
  606. var _61=this.openDelayTime;
  607. this.linkElem=_5a;
  608. this.popTimer=setTimeout(function(){
  609. _5c.showPreview(_59);
  610. },_61);
  611. var _62=this.dispDelayTime;
  612. this.dispTimer=setTimeout(function(){
  613. _5c.displayPreview();
  614. },_62);
  615. },loadSubSearchBar:function(){
  616. var _63="";
  617. if(cpvw_previewHandler.customSite=="google_search"){
  618. var _64=this.parentDoc.getElementsByTagName("input");
  619. for(var i=0;i<_64.length;i++){
  620. if(_64[i].getAttribute("name")=="q"){
  621. _63=_64[i].value;
  622. break;
  623. }
  624. }
  625. }else{
  626. if(cpvw_previewHandler.customSite=="yahoo_search"){
  627. var _64=this.parentDoc.getElementsByTagName("input");
  628. for(var i=0;i<_64.length;i++){
  629. if(_64[i].getAttribute("name")=="p"){
  630. _63=_64[i].value;
  631. break;
  632. }
  633. }
  634. }
  635. }
  636. if(_63==""){
  637. return;
  638. }
  639. cpvw_subSearchBar.selectedText=_63;
  640. },initPreviewHide:function(evt){
  641. var _67=this;
  642. _67.clearTimer(this.popTimer);
  643. _67.clearTimer(this.dispTimer);
  644. this.clearTimer(this.showSmallDivTimer);
  645. if(!_67.isShowingPreview){
  646. return;
  647. }
  648. _67.hideTimer=setTimeout(function(){
  649. _67.hidePreview(false);
  650. },cpvw_Delays.CLOSE_DELAY_TIME);
  651. },clearHideTimer:function(){
  652. this.clearTimer(this.hideTimer);
  653. },showPreview:function(_68){
  654. conDump("IN SHOW PREVIEW HREF TIMER "+_68+", "+this.popTimer);
  655. if(this.popTimer==null){
  656. return;
  657. }
  658. var _69,_6a;
  659. this.linkUrl=_68;
  660. var _6b=this;
  661. this.setPreviewDimensions();
  662. _6a=cpvw_previewHandler.getPreviewFrame();
  663. _69=cpvw_previewHandler.getPreviewWindow();
  664. cpvw_previewHandler.isContextMenu=false;
  665. if(!cpvw_jsUtils.isFF2()){
  666. _6a.loadURI(this.linkUrl);
  667. }else{
  668. _6a.setAttribute("src",this.linkUrl);
  669. }
  670. cpvw_previewHandler.isLoaded=false;
  671. if(cpvw_previewHandler.previewOpenMode!="click"){
  672. this.parentDoc.addEventListener("click",cpvw_previewHandler.hidePreview,true);
  673. }
  674. },setPreviewDimensions:function(){
  675. var doc=this.parentDoc;
  676. var _6d=document.getElementById("appcontent").boxObject.y+30;
  677. var _6e=this.screenX,_6f=this.screenY;
  678. this.dimPreview=new cpvw_previewSize();
  679. this.dimPreview.top=_6d;
  680. var _70=cpvw_prefHandler.getPref(cpvw_Prefs.prefPreviewSize);
  681. if(_70.indexOf(",")!=-1){
  682. this.dimPreview.width=parseInt(_70.split(",")[0]);
  683. this.dimPreview.height=parseInt(_70.split(",")[1]);
  684. if(_6e<document.getElementById("appcontent").boxObject.width/2){
  685. this.dimPreview.left=(_6e+40)<200?200:_6e+40;
  686. }else{
  687. var _71=getBrowser().selectedTab.getAttribute("coolirispreviews_dispStack");
  688. this.dimPreview.left=_6e-100-this.dimPreview.width;
  689. if(this.dimPreview.left<0||(_71=="show")){
  690. this.dimPreview.left=10;
  691. }
  692. }
  693. if(this.dimPreview.width+this.dimPreview.left>document.getElementById("appcontent").boxObject.width){
  694. this.dimPreview.width=document.getElementById("appcontent").boxObject.width-30-this.dimPreview.left;
  695. }
  696. if((this.dimPreview.left<_6e)&&(this.dimPreview.width+this.dimPreview.left>_6e)){
  697. this.dimPreview.width=_6e-10-this.dimPreview.left;
  698. }
  699. if(this.dimPreview.height+30>document.getElementById("appcontent").boxObject.height){
  700. this.dimPreview.height=document.getElementById("appcontent").boxObject.height-40;
  701. }
  702. }else{
  703. if(_6e<document.getElementById("appcontent").boxObject.width/2){
  704. this.dimPreview.left=(_6e+40)<200?200:_6e+40;
  705. }else{
  706. this.dimPreview.left=10;
  707. }
  708. if(_6e<document.getElementById("appcontent").boxObject.width/2){
  709. this.dimPreview.width=document.getElementById("appcontent").boxObject.width-30-this.dimPreview.left;
  710. }else{
  711. this.dimPreview.width=_6e-40;
  712. }
  713. this.dimPreview.height=document.getElementById("appcontent").boxObject.height-30;
  714. }
  715. var _72=cpvw_prefHandler.getPref(cpvw_Prefs.prefPreviewFixedLoc);
  716. if(_72=="yes"){
  717. var _73=cpvw_prefHandler.getPref(cpvw_Prefs.prefPreviewLoc);
  718. if(_73.indexOf(",")!=-1){
  719. this.dimPreview.left=parseInt(_73.split(",")[0]);
  720. this.dimPreview.top=parseInt(_73.split(",")[1]);
  721. if(this.dimPreview.top==0||this.dimPreview.top<0){
  722. this.dimPreview.top=_6d;
  723. }
  724. }
  725. if(_70.indexOf(",")!=-1){
  726. this.dimPreview.width=parseInt(_70.split(",")[0]);
  727. this.dimPreview.height=parseInt(_70.split(",")[1]);
  728. }
  729. }
  730. this.dimPreview.mouseX=_6e;
  731. this.dimPreview.mouseY=_6f;
  732. if(cpvw_previewHandler.customSite=="youtube_video"){
  733. var _74=cpvw_previewHandler.getPreviewFrame();
  734. _74.markupDocumentViewer.fullZoom=1;
  735. this.dimPreview.width=656;
  736. this.dimPreview.height=470;
  737. }
  738. },hidePreview:function(_75){
  739. if(this.hideTimer==null){
  740. return;
  741. }
  742. try{
  743. var _76=cpvw_previewHandler.hidePreview();
  744. if(_76){
  745. if(this.linkElem!=null){
  746. this.linkElem.setAttribute("style","color:brown;");
  747. }
  748. this.isShowingPreview=false;
  749. }
  750. }
  751. catch(ex){
  752. }
  753. },displayPreview:function(){
  754. var _77=cpvw_objOverlay.getContentDocument();
  755. if(_77==null||cpvw_docHandler==null){
  756. return;
  757. }
  758. if(this.dispTimer==null){
  759. return;
  760. }
  761. this.isShowingPreview=true;
  762. cpvw_previewHandler.showPreview(this.dimPreview,cpvw_previewHandler.customSite);
  763. cpvw_subSearchBar.showSearchBar();
  764. if(this.linkElem!=null){
  765. this.linkElem.style.color="orange";
  766. }
  767. },showImages:function(){
  768. var _78=cpvw_previewHandler.getPreviewFrame();
  769. var _79=_78.contentDocument.images;
  770. for(var i=0;i<_79.length;i++){
  771. _79[i].setAttribute("src",_79[i].src);
  772. }
  773. },previewOnLoad:function(evt){
  774. var _7c=this;
  775. var _7d=cpvw_previewHandler.getPreviewFrame();
  776. cpvw_previewHandler.isLoaded=true;
  777. if(cpvw_previewHandler.customSite=="google_video"){
  778. googleVideo_filter(_7d.contentDocument);
  779. }
  780. var _7e=cpvw_prefHandler.getPrefJson(cpvw_Prefs.jsonPrefZoom);
  781. conDump("zzzz oom tiype123 = "+_7e.zoomSetting);
  782. if(_7e.zoomSetting=="browser"){
  783. if(_7d.markupDocumentViewer!=null){
  784. setTimeout(function(){
  785. _7d.markupDocumentViewer.textZoom=cpvw_get("content").markupDocumentViewer.textZoom;
  786. _7d.markupDocumentViewer.fullZoom=cpvw_get("content").markupDocumentViewer.fullZoom;
  787. },100);
  788. }
  789. }else{
  790. if(_7e.zoomSetting=="previews"){
  791. if(_7e.zoomType=="text"){
  792. _7d.markupDocumentViewer.textZoom=_7e.zoomTextSize;
  793. }else{
  794. if(_7e.zoomType=="full"){
  795. _7d.markupDocumentViewer.fullZoom=_7e.zoomFullSize;
  796. }
  797. }
  798. }else{
  799. if(_7e.zoomSetting=="autofit"){
  800. conDump("zzzz oom tiype = "+cpvw_previewHandler.dimPreview.width+", "+_7d.contentDocument.defaultView.scrollMaxX+" "+_7d.contentDocument.defaultView.pageXOffset+" "+((cpvw_previewHandler.dimPreview.width-40)/_7d.contentDocument.documentElement.scrollWidth));
  801. if(_7d.contentDocument.defaultView.scrollMaxX>0){
  802. _7d.markupDocumentViewer.fullZoom=(cpvw_previewHandler.dimPreview.width-50)/(cpvw_previewHandler.dimPreview.width+_7d.contentDocument.defaultView.scrollMaxX);
  803. }
  804. }
  805. }
  806. }
  807. if(cpvw_previewHandler.customSite=="youtube_video"){
  808. var _7d=cpvw_previewHandler.getPreviewFrame();
  809. _7d.markupDocumentViewer.fullZoom=1;
  810. }
  811. this.doneHighlight=false;
  812. },startPiclensLite:function(){
  813. var doc=this.parentDoc;
  814. if(doc.loadPiclensJS!=1){
  815. doc.loadPiclensJS=1;
  816. var _80=doc.createElement("script");
  817. _80.setAttribute("type","text/javascript");
  818. _80.setAttribute("src","http://lite.piclens.com/current/piclens.js");
  819. var _81=doc.getElementsByTagName("head")[0];
  820. if(_81!=null){
  821. _81.appendChild(_80);
  822. }else{
  823. if(doc.body!=null){
  824. doc.body.appendChild(_80);
  825. }
  826. }
  827. }
  828. var _82=cpvw_previewHandler.getPreviewFrame();
  829. var _83=_82.contentDocument;
  830. var _84=this.parWindow;
  831. var _85=[];
  832. var _86=_83.getElementsByTagName("IMG");
  833. var _87=cpvw_prefHandler.getPref(cpvw_Prefs.prefPiclensFilterSize);
  834. var _88=_87.split(",");
  835. var _89=_88[0],_8a=_88[1];
  836. for(var i=0;i<_86.length;i++){
  837. var img=_86[i];
  838. var _8d=img.src;
  839. if(_8d==null){
  840. continue;
  841. }
  842. var _8e=img.parentNode;
  843. var m=0;
  844. var _90=_8d;
  845. while(_8e&&m<3){
  846. if(_8e.nodeType==Node.ELEMENT_NODE){
  847. if((_8e instanceof HTMLAnchorElement&&_8e.href)||_8e instanceof HTMLAreaElement||_8e instanceof HTMLLinkElement){
  848. _90=_8e.href;
  849. break;
  850. }
  851. }
  852. _8e=_8e.parentNode;
  853. m++;
  854. }
  855. if(_90!=_8d){
  856. var uri=Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
  857. uri.spec=_90;
  858. var _92=Components.classes["@mozilla.org/mime;1"].getService(Components.interfaces.nsIMIMEService);
  859. var _93;
  860. try{
  861. _93=_92.getTypeFromURI(uri);
  862. }
  863. catch(ex){
  864. _93="";
  865. }
  866. if(_93.indexOf("image")==-1){
  867. _90=_8d;
  868. }
  869. }
  870. if(_90==_8d){
  871. if(img.width<_89||img.height<_8a){
  872. continue;
  873. }
  874. }
  875. _85.push({"src":_90,"thumbnailSrc":_8d});
  876. }
  877. if(_85.length>0){
  878. setTimeout(function(){
  879. cpvw_jsUtils.showPiclensLite(_84,doc.title,doc.URL,_85,false);
  880. },1000);
  881. }else{
  882. alert("No images to view (Images might be filtered according to your filter criteria)");
  883. }
  884. },highlightText:function(how){
  885. var _95="";
  886. var _96=cpvw_previewHandler.getPreviewFrame();
  887. if(_96.contentDocument!=null&&_96.contentDocument.body!=null){
  888. if(cpvw_previewHandler.customSite=="google_search"){
  889. var _97=this.parentDoc.getElementsByTagName("input");
  890. for(var i=0;i<_97.length;i++){
  891. if(_97[i].getAttribute("name")=="q"){
  892. _95=_97[i].value;
  893. break;
  894. }
  895. }
  896. }else{
  897. if(cpvw_previewHandler.customSite=="yahoo_search"){
  898. var _97=this.parentDoc.getElementsByTagName("input");
  899. for(var i=0;i<_97.length;i++){
  900. if(_97[i].getAttribute("name")=="p"){
  901. _95=_97[i].value;
  902. break;
  903. }
  904. }
  905. }
  906. }
  907. if(_95==""){
  908. return;
  909. }
  910. this.arrHighlightText=_95.split(" ");
  911. if(this.arrHighlightText==null){
  912. return;
  913. }
  914. if(how=="show"){
  915. for(var i=0;i<this.arrHighlightText.length;i++){
  916. this.highlightWord("#FFFF99","black",this.arrHighlightText[i],_96.contentWindow);
  917. }
  918. this.doneHighlight=true;
  919. }else{
  920. for(var i=0;i<this.arrHighlightText.length;i++){
  921. this.removeHighlight(this.arrHighlightText[i],_96.contentWindow);
  922. }
  923. this.doneHighlight=false;
  924. }
  925. }
  926. },removeHighlight:function(_99,win){
  927. var _9b=false;
  928. for(var i=0;win.frames&&i<win.frames.length;i++){
  929. if(this.removeHighlight(aHighBackColor,aHighTextColor,_99,win.frames[i])){
  930. _9b=true;
  931. }
  932. }
  933. var doc=win.document;
  934. if(!doc||!(doc instanceof HTMLDocument)){
  935. return _9b;
  936. }
  937. var _9e=doc.body;
  938. var _9f=_9e.childNodes.length;
  939. this._searchRange=doc.createRange();
  940. this._startPt=doc.createRange();
  941. this._endPt=doc.createRange();
  942. this._searchRange.setStart(_9e,0);
  943. this._searchRange.setEnd(_9e,_9f);
  944. this._startPt.setStart(_9e,0);
  945. this._startPt.setEnd(_9e,0);
  946. this._endPt.setStart(_9e,_9f);
  947. this._endPt.setEnd(_9e,_9f);
  948. var _a0=null;
  949. var _a1=Components.classes["@mozilla.org/embedcomp/rangefind;1"].createInstance(Components.interfaces.nsIFind);
  950. while((_a0=_a1.Find(_99,this._searchRange,this._startPt,this._endPt))){
  951. var _a2=_a0.startContainer;
  952. var _a3=null;
  953. try{
  954. _a3=_a2.parentNode;
  955. }
  956. catch(ex){
  957. }
  958. if(_a3&&_a3.className=="__cooliris-search"){
  959. var _a4=null;
  960. var _a5=doc.createDocumentFragment();
  961. var _a6=_a3.nextSibling;
  962. var _a7=_a3.parentNode;
  963. while((_a4=_a3.firstChild)){
  964. _a5.appendChild(_a4);
  965. }
  966. this._startPt=doc.createRange();
  967. this._startPt.setStartAfter(_a3);
  968. _a7.removeChild(_a3);
  969. _a7.insertBefore(_a5,_a6);
  970. _a7.normalize();
  971. }else{
  972. this._startPt=doc.createRange();
  973. this._startPt.setStart(_a0.endContainer,_a0.endOffset);
  974. }
  975. this._startPt.collapse(true);
  976. }
  977. },highlightWord:function(_a8,_a9,_aa,win){
  978. var _ac=false;
  979. for(var i=0;win.frames&&i<win.frames.length;i++){
  980. if(this.highlightWord(_a8,_a9,_aa,win.frames[i])){
  981. _ac=true;
  982. }
  983. }
  984. var doc=win.document;
  985. if(!doc||!(doc instanceof HTMLDocument)){
  986. return _ac;
  987. }
  988. var _af=doc.body;
  989. var _b0=_af.childNodes.length;
  990. this._searchRange=doc.createRange();
  991. this._startPt=doc.createRange();
  992. this._endPt=doc.createRange();
  993. this._searchRange.setStart(_af,0);
  994. this._searchRange.setEnd(_af,_b0);
  995. this._startPt.setStart(_af,0);
  996. this._startPt.setEnd(_af,0);
  997. this._endPt.setStart(_af,_b0);
  998. this._endPt.setEnd(_af,_b0);
  999. var _b1=doc.createElementNS("http://www.w3.org/1999/xhtml","span");
  1000. _b1.style.backgroundColor=_a8;
  1001. _b1.style.color=_a9;
  1002. _b1.style.display="inline";
  1003. _b1.style.fontSize="inherit";
  1004. _b1.style.padding="0";
  1005. _b1.className="__cooliris-search";
  1006. return this.changeText(_aa,_b1)||_ac;
  1007. },changeText:function(_b2,_b3){
  1008. var _b4=null;
  1009. var _b5=Components.classes["@mozilla.org/embedcomp/rangefind;1"].createInstance().QueryInterface(Components.interfaces.nsIFind);
  1010. var _b6=false;
  1011. while((_b4=_b5.Find(_b2,this._searchRange,this._startPt,this._endPt))){
  1012. var _b7=_b3.cloneNode(true);
  1013. var _b8=this.highlight(_b4,_b7);
  1014. this._startPt=_b8.ownerDocument.createRange();
  1015. this._startPt.setStart(_b8,_b8.childNodes.length);
  1016. this._startPt.setEnd(_b8,_b8.childNodes.length);
  1017. _b6=true;
  1018. }
  1019. return _b6;
  1020. },highlight:function(_b9,_ba){
  1021. var _bb=_b9.startContainer;
  1022. var _bc=_b9.startOffset;
  1023. var _bd=_b9.endOffset;
  1024. var _be=_b9.extractContents();
  1025. var _bf=_bb.splitText(_bc);
  1026. var _c0=_bf.parentNode;
  1027. _ba.appendChild(_be);
  1028. _c0.insertBefore(_ba,_bf);
  1029. return _ba;
  1030. }};
  1031.  
  1032.